home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / du.arc / DU.H < prev    next >
C/C++ Source or Header  |  1990-10-05  |  5KB  |  144 lines

  1. /* @(#) du.h 1.3 90/09/09 10:24:49 */
  2.  
  3. /*
  4.  * Package:    du - Enhanced "du" disk usage replacement.
  5.  * File:    du.h - Header definitions.
  6.  *
  7.  * Sat Sep  8 14:34:56 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
  8.  *    Cleanup for distribution.
  9.  * Tue Apr 17 21:50:58 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
  10.  *    Original composition.
  11.  *
  12.  * Copyright 1990, Unicom Systems Development.  All rights reserved.
  13.  * See accompanying README file for terms of distribution and use.
  14.  */
  15.  
  16.  
  17. #define VERSION        "1"
  18.  
  19. /*
  20.  * PRINT_ERRORS - If enabled, "du" will print diagnostic messages (e.g.
  21.  * permission denied, etc.).  If disabled, "du" will print these messages
  22.  * only if "-r" is given.  The latter behaviour is compatible with the
  23.  * standard system "du".  The former behaviour is more sensible.
  24.  */
  25. #define PRINT_ERRORS    /**/
  26.  
  27. /*
  28.  * REPORT_BLOCKSIZE - The size of a block (in bytes) used in reporting
  29.  * disk usage.  Note that "du" will use the actual block size of a filesystem
  30.  * when computing the usage of an entry on that filesystem, but will then
  31.  * normalize all the results in terms of the reporting blocksize.  A
  32.  * value of "512" will produce results compatible with the standard system
  33.  * "du".  A value of "0" will use the native filesystem block size.  The
  34.  * "-b" command line option may be used to override this default.
  35.  */
  36. #define REPORT_BLKSIZE    512
  37.  
  38. /*
  39.  * MAX_BREAK - The maximum number of breakdown catagories which may be
  40.  * specified with the "-c" option.  This value will effect the size of
  41.  * (struct dskusage), and only a few of them are created, and thus this
  42.  * can be a reasonably large number without too much impact.
  43.  */
  44. #define MAX_BREAK    64
  45.  
  46. /*
  47.  * BROKE_MNTTAB - If defined, "du" will use it's own private description
  48.  * of the /etc/mnttab file rather than including /usr/include/mnttab.h.
  49.  * If you are running Interactive UNIX 2.0.2 you *must* enable this - your
  50.  * <mnttab.h> is broken.
  51.  */
  52. /*#define BROKE_MOUNTAB    /**/
  53.  
  54.  
  55. /*****************************************************************************
  56.  *
  57.  * End of site-specific customizations.
  58.  *
  59.  ****************************************************************************/
  60.  
  61. #define TRUE        1
  62. #define FALSE        0
  63.  
  64. /*
  65.  * Error severity codes.
  66.  */
  67. #define ERR_WARN    0
  68. #define ERR_ABORT    1
  69.  
  70. #ifndef Reg
  71. # define Reg        register
  72. #endif
  73.  
  74. #ifdef INTERN
  75. # define EXTERN
  76. #else
  77. # define EXTERN        extern
  78. #endif
  79.  
  80. /*
  81.  * A boolean true/false value.
  82.  */
  83. typedef int        BOOL;
  84.  
  85. /*
  86.  * Datatype used to accumulate disk usage stats.
  87.  */
  88. struct dskusage {
  89.     long b[MAX_BREAK];        /*  per days as specified Breakdown[]          */
  90. };
  91.  
  92. /*
  93.  * Structure used to store information on mounted filesystems.
  94.  */
  95. struct fsinfo {
  96.     int dev;            /* the device number            */
  97.     int nino;            /* number of available inodes        */
  98.     int bsize;            /* size of a block on this device    */
  99.     int nindir;            /* number direct addresses in a block   */
  100.     unsigned char *idone;    /* bit vector of linked inodes done    */
  101.     struct fsinfo *next;    /* pointer to next item in linked list    */
  102. };
  103.  
  104. /*
  105.  * General globals.
  106.  */
  107. EXTERN char *Progname;        /* this program's name                  */
  108. EXTERN char *Curr_dir;        /* working dir where prog was started          */
  109. EXTERN long Curr_time;        /* time at which du was started              */
  110.  
  111. /*
  112.  * Boolean options set by command line switches.
  113.  */
  114. EXTERN BOOL Accum_subdirs;    /* add usage of a subdir into parent's usage  */
  115. EXTERN BOOL All_entries;    /* show everything, not just directories      */
  116. EXTERN BOOL Cross_filesys;    /* continue down dirs across filesystems      */
  117. EXTERN BOOL Descend_dirs;    /* follow directories recursively          */
  118. EXTERN BOOL Suppress_repeats;    /* report multiply linked files only once     */
  119. EXTERN BOOL Print_errors;    /* display error messages              */
  120. EXTERN BOOL Skip_links;        /* ignore multiply-linked regular files          */
  121. EXTERN BOOL Total_only;        /* only print total usage for entire dir tree */
  122.  
  123. /*
  124.  * Other options set by command line switches.
  125.  */
  126. EXTERN int Report_blksize;    /* report usage in terms of blocks this size  */
  127. EXTERN int Num_break;        /* breakdown usage reported to this many cols */
  128. EXTERN int Breakdown[MAX_BREAK];/* each col is usage more than this many days */
  129.  
  130. /*
  131.  * Local procedures.
  132.  */
  133. void        errmssg();    /* display a diagnostic message             */
  134. void        du_entry();    /* determine usage of a particular entry     */
  135. void        fs_initinfo();    /* initialize filesystem information         */
  136. struct fsinfo *    fs_getinfo();    /* get filesystem information             */
  137. int        fs_linkdone();    /* determine whether a file has been visited */
  138. long        fs_numblocks();    /* count number of blocks used by an entry   */
  139. void        set_usage();    /* set a disk usage value             */
  140. void        add_usage();    /* accumulate a disk usage value         */
  141. void        print_usage();    /* display a disk usage value             */
  142. void *        xmalloc();    /* allocate memory with error checking         */
  143.  
  144.